package com.woniu.woniuproject.controller.admin;

import com.woniu.woniuproject.Job.Thread;
import com.woniu.woniuproject.entity.Product;
import com.woniu.woniuproject.service.ProductService;
import com.woniu.woniuproject.utils.ResponseResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 功能描述:<br>
 * 〈〉
 *
 * @author EDZ
 * @create 2020/11/18
 * @since 1.0.0
 */
@RestController
@RequestMapping("product")
public class ProductController {

    Logger logger = LoggerFactory.getLogger(Thread.class);
    @Autowired
    ProductService productService;
    @GetMapping("queryall")
    public ResponseResult<List<Product>> queryall(){
        List<Product> queryall = productService.queryall();
        return new ResponseResult<>(queryall);
    }

    @GetMapping("addone")
    public ResponseResult<Integer> addone(Product tableData1){
        tableData1.setStatus("1");
        int i=productService.addone(tableData1);
        return new ResponseResult<>(i);
    }

    @GetMapping("updateone")
    public ResponseResult<Integer> updateone(Product tableData1){
        tableData1.setStatus("1");
        int i=productService.updateone(tableData1);
        return new ResponseResult<>(i);
    }

    @GetMapping("deleteone")
    public ResponseResult<Integer> deleteone(int id){
        System.out.println(id+"================");
        int i=productService.deleteone(id);
        System.out.println(i+"=====================");
        return new ResponseResult<>(i);
    }
}